package br.usp.ime.lab.analyzer;
import java.util.Vector;

import junit.framework.Assert;

import org.junit.Before;
import org.junit.Test;

import br.usp.ime.lab.analyzer.ConditionAnalyzer;
import br.usp.ime.lab.analyzer.ConditionAnalyzerImpl;

import recoder.abstraction.Method;



public class ConditionAnalyzerImplTest {

	/**
	 * Classe usada para validar a interface ConditionAnalyzer.
	 */
	
	private ConditionAnalyzer conditionAnalyzer;

	@Before
	public void setUp() {
		conditionAnalyzer = new ConditionAnalyzerImpl();
	}

	@Test
	public void testGetAstEmpty() throws Exception {
		Vector<Method> ast = conditionAnalyzer.getAst("D:\\", "");
		Assert.assertEquals(new Vector<Method>(), ast);
	}

	@Test
	public void testGetAst() throws Exception {
		Vector<Method> ast = conditionAnalyzer.getAst("src", "br.usp.ime.lab.analyzer");
		for (Method method : ast) {
			Assert.assertTrue(getExpectedMethods().contains(method.toString()));
		}
	}

	private Vector<String> getExpectedMethods() {
		Vector<String> expectedMethods = new Vector<String>();
		expectedMethods.add("<MethodDeclaration> getAst(2)");
		expectedMethods.add("<MethodDeclaration> getAllDecisions(1)");
		expectedMethods.add("<MethodDeclaration> getAllConditions(1)");
		expectedMethods.add("<MethodDeclaration> getAllMCDC(1)");
		expectedMethods.add("<MethodDeclaration> getAllDecisions(2)");
		expectedMethods.add("<MethodDeclaration> getAllConditions(2)");
		expectedMethods.add("<MethodDeclaration> getAllMCDC(2)");
		expectedMethods.add("<MethodDeclaration> getAst(2)");
		expectedMethods.add("<MethodDeclaration> getAllDecisions(1)");
		expectedMethods.add("<MethodDeclaration> getAllConditions(1)");
		expectedMethods.add("<MethodDeclaration> getAllMCDC(1)");
		expectedMethods.add("<MethodDeclaration> getAllDecisions(2)");
		expectedMethods.add("<MethodDeclaration> getAllConditions(2)");
		expectedMethods.add("<MethodDeclaration> getAllMCDC(2)");
		expectedMethods.add("<MethodDeclaration> getAst(2)");
		expectedMethods.add("<MethodDeclaration> getAllDecisions(1)");
		expectedMethods.add("<MethodDeclaration> getAllConditions(1)");
		expectedMethods.add("<MethodDeclaration> getAllMCDC(1)");
		expectedMethods.add("<MethodDeclaration> getAllDecisions(2)");
		expectedMethods.add("<MethodDeclaration> getAllConditions(2)");
		expectedMethods.add("<MethodDeclaration> getAllMCDC(2)");
		expectedMethods.add("<MethodDeclaration> getMCDC(1)");
		expectedMethods.add("<MethodDeclaration> getMCDCRecursively(3)");
		expectedMethods.add("<MethodDeclaration> getDecisionElements(1)");
		expectedMethods.add("<MethodDeclaration> getConditionElements(1)");
		expectedMethods.add("<MethodDeclaration> getMethods(1)");
		expectedMethods.add("<MethodDeclaration> saveXML(2)");
		expectedMethods.add("<MethodDeclaration> getAst(2)");
		expectedMethods.add("<MethodDeclaration> getAllDecisions(1)");
		expectedMethods.add("<MethodDeclaration> getAllConditions(1)");
		expectedMethods.add("<MethodDeclaration> getAllMCDC(1)");
		expectedMethods.add("<MethodDeclaration> getAllDecisions(2)");
		expectedMethods.add("<MethodDeclaration> getAllConditions(2)");
		expectedMethods.add("<MethodDeclaration> getAllMCDC(2)");
		expectedMethods.add("<MethodDeclaration> getAst(2)");
		expectedMethods.add("<MethodDeclaration> getAllDecisions(1)");
		expectedMethods.add("<MethodDeclaration> getAllConditions(1)");
		expectedMethods.add("<MethodDeclaration> getAllMCDC(1)");
		expectedMethods.add("<MethodDeclaration> getAllDecisions(2)");
		expectedMethods.add("<MethodDeclaration> getAllConditions(2)");
		expectedMethods.add("<MethodDeclaration> getAllMCDC(2)");
		expectedMethods.add("<MethodDeclaration> getMCDC(1)");
		expectedMethods.add("<MethodDeclaration> getMCDCRecursively(3)");
		expectedMethods.add("<MethodDeclaration> getDecisionElements(1)");
		expectedMethods.add("<MethodDeclaration> getConditionElements(1)");
		expectedMethods.add("<MethodDeclaration> getMethods(1)");
		expectedMethods.add("<MethodDeclaration> saveXML(2)");
		expectedMethods.add("<MethodDeclaration> getAst(2)");
		expectedMethods.add("<MethodDeclaration> getAllDecisions(1)");
		expectedMethods.add("<MethodDeclaration> getAllConditions(1)");
		expectedMethods.add("<MethodDeclaration> getAllMCDC(1)");
		expectedMethods.add("<MethodDeclaration> getAllDecisions(2)");
		expectedMethods.add("<MethodDeclaration> getAllConditions(2)");
		expectedMethods.add("<MethodDeclaration> getAllMCDC(2)");
		return expectedMethods;
	}

}
